package ranab.jar;

import java.util.*;
import java.util.zip.*;

/**
 * This class contains <code>JarObserver</code> objects. This
 * class is itself a <code>JarObserver</code> class. 
 * 
 * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
 */
public
class JarObserverContainer extends Vector implements JarObserver {
	
   /**
	* default constructor
	*/
	public JarObserverContainer()  {
	}
	
	/**
	 * add observer
	 */
	public void addObserver(JarObserver observer)  {
		if (!contains(observer))  {
			add(observer);
		}
	} 
	
	/**
	 * remove observer
	 */
	public void removeObserver(JarObserver observer)  {
		if (contains(observer))  {
			remove(observer);
		}
	}
	
	/**
	 * start observing
	 */
	public void start()  {
		for(int i=0; i<size(); i++)  {
			JarObserver obsr = (JarObserver)elementAt(i);
			obsr.start();
		}
	}
	
	/**
	 * set count
	 */
	public void setCount(int count) {
		for(int i=0; i<size(); i++)  {
			JarObserver obsr = (JarObserver)elementAt(i);
			obsr.setCount(count);
		}
	}
	
	/**
	 * set next entry
	 */
	public void setNext(ZipEntry je) {
		for(int i=0; i<size(); i++)  {
			JarObserver obsr = (JarObserver)elementAt(i);
			obsr.setNext(je);
		}
	}
	
	/**
	 * set error message
	 */
	public void setError(String errMsg) {
		for(int i=0; i<size(); i++)  {
			JarObserver obsr = (JarObserver)elementAt(i);
			obsr.setError(errMsg);
		}
	}
	
	/**
	 * stop observing
	 */
	public void end() {
		for(int i=0; i<size(); i++)  {
			JarObserver obsr = (JarObserver)elementAt(i);
			obsr.end();
		}
	}
}